package current.security.user.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import office.bo.system.Department;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Proxy;

import com.sun.istack.internal.NotNull;
/**
 * <p>
 * Title: an User.java file of the portal project.
 * </p>
 * <p>
 * Description: 获取用户信息
 * </p>
 * <p>
 * Create Time: 2010-04-14 下午02:10:34
 * </p>
 * <p>
 * Company: baiqinghai
 * </p>
 * 
 * @author baiqinghai
 * 
 * @version 1.0
 */
@Proxy(lazy = true)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Entity(name="User")
@Table(name="TBL_USER")
public class User{

	private static final long serialVersionUID = 8026813053768023527L;
	//主键ID
	@Id
	@GenericGenerator(name="idGenerator", strategy="uuid") //这个是hibernate的注解
	@GeneratedValue(generator="idGenerator") //使用uuid的生成策略
	private String id;
	//登陆用户名
	@NotNull
	private String name;
	//中文名称
	private String cname;
	//密码
	@NotNull
	private String password;
	//备注
	private String memo;
	//是否可以使用
	/** 是否正常使用 0为已禁止 1为正常使用 */
	@NotNull
	private Integer status;
	//角色集合列表
	 //mappedBy 说明User不负责维护关系
    @OneToMany(cascade=CascadeType.ALL,fetch = FetchType.LAZY,mappedBy="user")
	private Set<U_Role> roles = new HashSet<U_Role>();
	//公司ID
	private Integer companyId;
	//部门ID
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="departmentId")
	private Department department;
	//职务
	private String office;
	/*
	 * (non-Javadoc)
	 */
	public String getPassword() {
		return password;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	} 
	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	} 
	
	public Integer getStatus() {
		return status;
	}
 
	public String getCname() {
		return cname;
	}

	public void setCname(String cname) {
		this.cname = cname;
	}
	/**
	 * @return the companyId
	 */
	public Integer getCompanyId() {
		return companyId;
	}
	/**
	 * @param companyId the companyId to set
	 */
	public void setCompanyId(Integer companyId) {
		this.companyId = companyId;
	}
	public String getMemo() {
		return memo;
	}
	public void setMemo(String memo) {
		this.memo = memo;
	}
 
	public void setStatus(Integer status) {
		this.status = status;
	}
	public Set<U_Role> getRoles() {
		return roles;
	}
	public void setRoles(Set<U_Role> roles) {
		this.roles = roles;
	}
	public Department getDepartment() {
		return department;
	}
	public void setDepartment(Department department) {
		this.department = department;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getOffice() {
		return office;
	}
	public void setOffice(String office) {
		this.office = office;
	}

}